RESTful and JSON remoting

Configuring JSON remoting

Define a service/façade layer:

Create a service layer that acts as a façade that exposes all the PizzaShop functionalities. This is required if you want to integrate a RESTful remoting web service. Other common use case for service layers is e.g. security.

service type --interface ~.service.ToppingService --entity ~.domain.Topping
service type --interface ~.service.BaseService --entity ~.domain.Base
service type --interface ~.service.PizzaService --entity ~.domain.Pizza
service type --interface ~.service.PizzaOrderService --entity ~.domain.PizzaOrder

Adding JSON remoting

Configure JSON-based MVC controllers for all domain types:

json all --deepSerialize
web mvc json setup
web mvc json all --package ~.web

Configure regular web-based MVC controllers for all domain types:

web mvc setup
web mvc all --package ~.web

Due to a still unsolved issue in Spring ROO, generating JSON controllers with web mvc json setup does not work anymor after running once web mvc setup to generate regular web controllers:

roo> web mvc json setup
Command 'web mvc json setup' was found but is not currently available

To solve that issue, the @RooWebJson tag can be added to the controller (e.g. PizzaController), and ROO will automatically generate the Aspect that adds the JSON implementation:

@RooWebJson(jsonObject = Pizza.class)

Testing

Test again the JSON remoting services against the newly created application

...and you're done!